package com.blue.service;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.sql.Time;

public class TimerInvocationHandler implements InvocationHandler {
    private final Object target;

    public TimerInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        long start = System.currentTimeMillis();
        Object obj = method.invoke(target, args);
        long end = System.currentTimeMillis();
        System.out.println("耗时 " + (end - start) + "毫秒!");
        return obj;
    }
}
